import React, {Component} from 'react'
import {
    BrowserRouter as Router,
    Route,
    Switch
} from 'react-router-dom';
import {renderRoutes} from 'react-router-config'

import App from '$components/app/app'
import Home from '$containers/home/home'
import UserInfo from '$containers/userInfo/userInfo'
import Error404 from '$containers/error404/error404'

const routers = [
    {
        component: App,
        routes: [
            {
                path: '/',
                exact: true,
                component: Home,
                routes: []
            },
            {
                path: '/userInfo/:id?/:name?',
                component: UserInfo,
                onEnter: ({params}) => {
                    console.log(params,888);
                }
            }          
        ]
    },
    {
        path: '*',
        component: Error404
    }
]

class Routers extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <Router>
                {renderRoutes(routers)}
            </Router>
        )
    }
}

export default Routers